<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/includes/config.inc.php');
include_once("config.php");
getConfig();
checkActiveLogin();
if(isset($_GET['switch'])){
	$sql = "UPDATE `tbUsers` SET `sLevel` = :level WHERE `sUname` = :uname";
	if($_GET['switch'] == 'aps'){
		db::Query($sql, array(':level'=>"Administrator", ":uname"=>$_SESSION['username']));
	}
	if($_GET['switch'] == 'tps'){
		db::Query($sql, array(':level'=>"Technology Support Center", ":uname"=>$_SESSION['username']));
	}
	if($_GET['switch'] == 'kps'){
		db::Query($sql, array(':level'=>"Business Lab", ":uname"=>$_SESSION['username']));
	}
	if($_GET['switch'] == 'dps'){
		db::Query($sql, array(':level'=>"Desktop Support", ":uname"=>$_SESSION['username']));
	}
}
getUserInfo();
if($CONFIG['siteDown'] == 'true' and $USER['sUname'] != "kpeterson5"){
	gotoPage("down.php");
	exit;
}
$CONFIG['enableRightColumn'] = false;
$christmas = false;
$newyear = false;
//if($USER['sUname'] == 'kpeterson5'){
$NEWTEMPLATE = true;
//}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo getPortalName() ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<link href="css/layout.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="all" href="css/sexyalertbox.css"/>
<link rel="stylesheet" type="text/css" media="all" href="css/jquery.timepickr.css"/>
<link rel="stylesheet" type="text/css" media="all" href="css/jquery.tooltip.css"/>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<!--[if lt IE 7]>

	<link href="ie_style.css" rel="stylesheet" type="text/css" />

   <script type="text/javascript" src="ie_png.js"></script>

   <script type="text/javascript">

       ie_png.fix('.png');

   </script>

<![endif]-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="http://jquery-utils.googlecode.com/svn/trunk/src/jquery.anchorHandler.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/highcharts.js"></script>
<script type="text/javascript" src="js/sexyalertbox.v1.2.jquery.js"></script>
<script type="text/javascript" src="js/jquery.ui.all.js"></script> 
<script type="text/javascript" src="js/jquery.tooltip.js"></script> 
<script type="text/javascript" src="js/jsnow.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script>
$(document).ready(function(){
  Sexy.initialize();
  <?php if(isset($_GET['msg'])){ ?>
  Sexy.alert('<?php echo $_GET['msg'] ?>');
  <?php } ?>
  <?php if(isset($_GET['err'])){ ?>
  Sexy.error('<?php echo $_GET['err'] ?>');
  <?php } ?>
  <?php if($usr_info['sUname'] == 'tjbebon'){ ?>
  checkDown();
  <?php } ?>
  jQuery.noConflict();
  <?php if($christmas and date('j') != 6){ ?>
  jQuery().jSnow({flakes: 100, flakeColor: '#cccccc'});
  <?php } ?>
  <?php
  if(getPortalPrefix() == "aps_"){ 
  	$CONFIG['current_mysql_credentials']['mysql_database'] = 'inventory';
  	$CONFIG['current_mysql_credentials']['mysql_user'] = 'inventory';
  	$CONFIG['current_mysql_credentials']['mysql_pass'] = '8DNWxqKDNhTwdBfY';
  	db::disconnect();
  	$sql = "SELECT DISTINCT `sIdentifier` FROM `tbModerator` WHERE `iApprovalStatus` = 0";
  	$q = db::Query($sql);
  	$moderatorCount = 0;
  	while($row = $q->fetch()){
  		$moderatorCount ++;
  	}
	if($moderatorCount != 0){
		?>
		moderator();
		<?php
	}
	$CONFIG['current_mysql_credentials']['mysql_database'] = 'techcenter';
	$CONFIG['current_mysql_credentials']['mysql_user'] = 'techcenter';
	$CONFIG['current_mysql_credentials']['mysql_pass'] = 'Btv6Et6ARThrjbQb';
	db::disconnect();
  }
  ?>
});

function moderator(){
		jQuery('#moderatora').css('font-weight', 'bold');
		jQuery('#moderatora').animate({color:'#ffff66'}, 300, function(){jQuery('#moderatora').animate({color:'#e5e5e5'}, 100);setTimeout('moderator()', 700);});
	}
-->
</script>
<style>
.box2, .box, .list2{
	background-color:#FFFFFF;
}

body{
	background-image:url(images/pattern_062.gif);
	background-repeat:repeat;
	padding:0px;
}

#header{
	height:auto;
}

.row-1{
	text-align:center;
	margin:0px;
	margin-bottom:-35px;
	padding:0px;
	height:auto !important;
}

.fleft {
	padding:0px;
	margin:0px;
}

.fright {
	height: 1px;
	padding:0px;
}

#content{
	padding-left: 20px;
	padding-right:20px;
}

.box{
	border:1px #666 solid !important;
	padding-top:0px;
}

#boxcontent{
	padding-left: 5px;
	padding-right:5px;
}

.box h3, .box h1{
	font-size:18px;
	font-family:Arial, Helvetica, sans-serif;
	font-weight:bold;
	color:#000;
	border:none;
	border-bottom:1px #666 solid;
	background-color:#CCC;
	margin-top:0px;
	text-align:center;
	width:auto;
	padding-top:5px;
	padding-bottom:-5px;
}

.box h1{
	margin-left:-5px;
	margin-right:-5px;
}
</style>
</head>
<body id="page1">
<?php if($CONFIG['siteDown'] == 'true'){ ?>
<div style="width:100%; background-color:#F00; height:30px; font-size:24px; padding-top:10px; position:fixed; margin-left:-20px; z-index:999" align="center">
THE PORTAL SYSTEM IS DOWN
</div>
<?php } ?>
<div id="main-width">
  <div id="main">
    <!-- header -->
    <div id="header" class="png">
      <div class="row-1">
        <div class="fleft">
        	<img alt="" height="60" src="images/<?php echo getPortalPrefix() ?>logo.png" class="png" />
            <div class="messagebox" style="margin-top:5px;" align="center">
            <table align="center">
            	<tr>
               	<td align="center">
            	<strong style="font-size:12px; color:#000">
                	Welcome, <?php echo $USER['sFname']." ".$USER['sLname']; ?><br/>
					<?php echo date("l").", ".date("F j, Y") ?><br/>
                    Current Weather Conditions: <?php echo getWeather(); ?>
                </strong>
                </td>
                <td align="center" style="padding-left:25px;">
                <strong style="font-size:12px; color:#000">
                Having Problems?<br/>
                Contact Kody x6920<br/>
                <a href="https://www.edison.edu/webservices/internal/request/login_page.php" target="_blank">Submit a Bug Report</a>
                </strong>
                </td>
                </tr>
            </table>
            </div>
        </div>
        <div class="fright">
        </div>
      </div>
      <div class="row-2">
      <div id="copyright" style="display:none">Copyright &copy; 2011 <a href="http://apycom.com/">Apycom jQuery Menus</a></div>
        <div id="menu">
	    <ul class="menu">
        <li><a href="index.php" ><span><?php echo getPortalName() ?> Home</span></a></li>
        <?php if(getPortalPrefix() == "tps_" or getPortalPrefix() == "aps_"){ ?>
        <li><a href="/inventory2/" class="parent"><span id="moderatora">Inventory Application</span></a>
            <ul>
	            <?php if(getPortalPrefix() == "aps_"){ ?>
                <li><a href="/inventory2/moderator.php"><span>Moderation Que</span></a></li>
                <?php } ?>
            	<li><a href="/inventory2/"><span>Inventory Home</span></a></li>
                <li><a href="/inventory2/moveasset.php"><span>Move An Asset</span></a></li>
                <li><a href="/inventory2/askcamp.php?mode=annualinventory"><span>Annual Inventory</span></a></li>
            </ul>
        </li>
        <?php }else{ ?>
        <li><a href="/inventory/" class="parent"><span id="moderatora">Inventory Application</span></a>
            <ul>
	            <?php if(getPortalPrefix() == "aps_"){ ?>
                <li><a href="/inventory/moderator.php"><span>Moderation Que</span></a></li>
                <?php } ?>
            	<li><a href="/inventory/"><span>Inventory Home</span></a></li>
                <li><a href="/inventory/moveasset.php"><span>Move An Asset</span></a></li>
                <li><a href="/inventory/askcamp.php?mode=annualinventory"><span>Annual Inventory</span></a></li>
            </ul>
        </li>
        <?php } ?>
        <?php if(getPortalPrefix() != "dps_"){ ?>
        <li><a href="PALMS.php"><span>P.A.L.M.S.</span></a></li>
        <?php } ?>
        <li class="last"><a href="Cow_Tracker.php"><span>C.O.W. Tracking System</span></a></li>
        <?php if(getPortalPrefix() == "tps_"){ ?>
        <li><a href="Classroom_Down_Center.php"><span>Submit Classroom Down</span></a></li>
        <li><a href="Customer_Signin_Center.php"><span>Sign-In Customer</span></a></li>
		<li><a href="S_Building_Control_Center.php"><span>S-Building Control Center</span></a></li>
        <?php } ?>
        <?php if(getPortalPrefix() == "aps_"){ ?>
        <li><a href="Classroom_Down_Center.php"><span>Submit Classroom Down</span></a></li>
        <li><a href="Customer_Signin_Center.php"><span>Sign-In Customer</span></a></li>
        <li><a href="Announcement_Control_Center.php"><span>Announcement Control Center</span></a></li>
        <li><a href="Weekly_Parature_Report.php"><span>Weekly Parature Report</span></a></li>
        <?php } ?>
        <?php if(getPortalPrefix() == "kps_"){ ?>
        <li><a href="Classroom_Down_Center.php"><span>Submit Classroom Down</span></a></li>
        <li><a href="Customer_Signin_Center.php"><span>Sign-In Customer</span></a></li>
        <li><a href="K103_Control_Center"><span>K-103 Control Center</span></a></li>
        <?php } ?>
        <?php if(getPortalPrefix() == "dps_"){ ?>
        <li><a href="https://d2.parature.com/ics/service/loginSQL.asp" target="_blank"><span>Parature Login</span></a></li>
        <li><a href="Weekly_Parature_Report.php"><span>Weekly Parature Report</span></a></li>
        <?php } ?>
    </ul>
</div>
      </div>
    </div>
    <!-- content -->
    <div id="content">
      <div class="wrapper">
        <div class="sidebar">
          <div class="indent">
            <div class="widget">
              <div class="box">
              	<h3>Main Menu</h3>
                	<ul class="list1">
                         <li>&raquo; <a href="logout.php">Log Out</a></li>
                         <li>&raquo; <a href="Desktop_Tech_Center.php">Desktop Tech Center</a></li>
                         <?php if(getPortalPrefix() != "dps_"){ ?>
						 <li>&raquo; <a href="K103_Control_Center.php">K-103 Control Center</a></li>
						 <li>&raquo; <a href="Hardware_Software_Center.php">Hardware-Software Loan Center</a></li>
                         <?php } ?>
						 <li>&raquo; <a href="http://www.edison.edu/directory/" target="_blank">Edison Directory</a></li>
                         <?php if(getPortalPrefix() != "dps_"){ ?>
						 <li>&raquo; <a href="Registration_Assistance.php">Registration Assistance</a></li>
						 <li>&raquo; <a href="Quick_Help.php">Quick Help</a></li>
                         <?php } ?>
						 <li>&raquo; <a href="Registration_Count.php">Registration Counts</a></li>
						 <li>&raquo; <a href="Printer_Count.php">Printer Counts</a></li>
                         <?php if(getPortalPrefix() == "aps_"){ ?>
						 <li>&raquo; <a href="User_Control_Center.php">User Control Center</a></li>
						 <li>&raquo; <a href="codes.php">Activation Codes</a></li>
                         <?php } ?>
                    </ul>
               </div>
            </div>
            
            <div id="systems">
				<?php include("systems.php"); ?>
            </div>
            
            <?php if(getPortalPrefix() == "aps_"){ ?>
            <div id="employees">
				<?php include("employees.php"); ?>
            </div>
            <?php } ?>
            
            <?php
			$show = false;
			$temp = explode(", ", $CONFIG['admins']);
			foreach($temp as $value){
				if($value == $USER['sUname']){
					$show = true;
				}
			}
			if($show){
			?>
            <div id="changePortal">
				<?php include("changePortal.php"); ?>
            </div>
            <?php } ?>
            
          </div>
        </div>
        <div class="center">
          <div class="extra-wrap">
            <div class="wrapper">
              <div class="col-1" style="width:100%">
                <div class="extra-wrap">
                  <?php if(getPortalPrefix() == "aps_" and $moderatorCount != 0){ ?>
                  <div class="warning">
	               	<?php echo $USER['sFname'] ?>, there are <strong><?php echo $moderatorCount ?></strong> items in the moderation que for inventory.
                  </div>
                  <?php } ?>
                  <?php if($USER['sLevel'] == 'Technology Support Center' or $USER['sLevel'] == 'Business Lab'){ ?>
                  <?php if(date('d') == 14 or date('d') == 15 or date('d') == 16 or date('d') == 29 or date('d') == 30 or date('d') == 31 or date('d') == 1){ ?>
	              <div class="warning">
	               	<?php echo $USER['sFname'] ?>, have you completed your time sheet yet? If not, <a href="Payroll Time Sheet.xlsx" target="_blank">Click Here</a>
    	          </div>
                  <?php }elseif(checkLastSBuilding()){ ?>
                  <div class="info">
                  	<?php echo $USER['sFname'] ?>, it has been over 6 hours since the last S-Building report. It might be time to take a stroll on down there.
                  </div>
                  <?php }elseif(checkLastInventory()){ ?>
                  <?php if($CONFIG['enableInventoryReminder'] == 'true'){ ?>
                  <div class="error">
                  	<?php echo $USER['sFname'] ?>, it has been over 6 hours since the last annual inventory process. It might be time to do some inventory.
                  </div>
                  <?php } ?>
				  <?php } ?>
                  <?php } ?>
				  <?php if($USER['sLevel'] != 'Technology Support Center' and $USER['sLevel'] != 'Business Lab'){ ?>
                  <?php if($USER['sParatureToken'] != ''){?>
                  <?php
				  $sql = "SELECT * FROM `tbReports` WHERE `sUname` = :uname AND `iWeek` = :week AND `iYear` = :year";
				  $q = db::Query($sql, array(':uname'=>$USER['sUname'], ':week'=>date("W"), ':year'=>date("Y")));
				  $REPORT = $q->fetch();
				  if($REPORT['sStatus'] != "Complete" and (date("N") == 5 or date("N") == 4)){
				  ?>
	              <div class="error">
	               	<?php echo $USER['sFname'] ?>, you have yet to finalize your Weekly Parature Report. Please do so prior to 8:30 PM <?php if(date("N") == 4){ ?>on Friday<?php }else{ ?>tonight<?php } ?>.
                  </div>
                  <?php
				  }
				  ?>
                  <?php if($PARATURE['iTicketsOpen'] > 0){ ?>
                  <div class="warning">
	               	<?php echo $USER['sFname'] ?>, you have <strong><?php echo $PARATURE['iTicketsOpen']; ?></strong> tickets open as of <?php echo date("M j, Y @ g:i A", $PARATURE['iLastUpdate']) ?>
                  </div>
                  <?php } ?>
                  <?php } ?>
                  <?php } ?>
<?php if(getPageFileName() == "index"){ ?>
<table width="100%" cellspacing="5">
	<tr>
    	<td width="50%">
		<div class="box">
		<div id="boxcontent">
        	<h1>Printer Status</h1>
            <table width="100%">
            	<tr>
                	<td>
		            Upstairs Registration:<br/>
		            <div style="margin-left:10px;">
			        	<?php echo getPrinterInfo('192.168.11.158', 'toner') ?><br/>
			        	<?php echo getPrinterInfo('192.168.11.158', 'paper') ?>
		            </div>
					</td>
                    <td>
		            Downstairs S-112:<br/>
		            <div style="margin-left:10px;">
			        	<?php echo getPrinterInfo('192.168.11.3', 'toner') ?><br/>
			            <?php echo getPrinterInfo('192.168.11.3', 'paper') ?>
		            </div>
                   	</td>
				</tr>
			</table>
            <br/>
        </div>
        </div>
        <br/>
        <div class="box">
		<div id="boxcontent">
        	<h1>Todays Goals</h1>
            <table width="100%">
            	<tr>
                	<td align="center">
            <?php
			$sql = "SELECT COUNT(*) as `sCount` FROM `tbSignins` WHERE `sDateTime` LIKE :date";
			$q = db::Query($sql, array(':date'=>date("F j, Y")."%"));
			$r = $q->fetch();
			?>
            <?php echo $r['sCount'] ?> / 15
            		</td>
                    <td align="center">
            <?php
			$sql = "SELECT COUNT(*) as `sCount` FROM `tbSBuildingReports` WHERE `sDate` = :date";
			$q = db::Query($sql, array(':date'=>date("n/j/Y")));
			$r = $q->fetch();
			?>
            <?php echo $r['sCount'] ?> / 2
            		</td>
                    <td align="center">
            <?php
            $CONFIG['current_mysql_credentials']['mysql_database'] = 'inventory';
			$CONFIG['current_mysql_credentials']['mysql_user'] = 'inventory';
			$CONFIG['current_mysql_credentials']['mysql_pass'] = '8DNWxqKDNhTwdBfY';
			db::disconnect();
			$sql = "SELECT COUNT(*) as `sCount` FROM `tbLog` WHERE `tTimeStamp` > :time";
			$q = db::Query($sql, array(':time'=>strtotime(date("n/j/Y"))));
			$r = $q->fetch();
			$CONFIG['current_mysql_credentials']['mysql_database'] = 'techcenter';
			$CONFIG['current_mysql_credentials']['mysql_user'] = 'techcenter';
			$CONFIG['current_mysql_credentials']['mysql_pass'] = 'Btv6Et6ARThrjbQb';
			db::disconnect();
			?>
            <?php echo $r['sCount'] ?> / 150
            		</td>
                    </tr>
                    <tr>
                    <td align="center">
                    Customer Sign-Ins
                    </td>
                    <td align="center">
                    S-Building Reports
                    </td>
                    <td align="center">
                    Inventory Actions
                    </td>
				</tr>
            </table>
            <br/>
        </div>
        </div>
        </td>
        <td>
		<div class="box">
		<div id="boxcontent">
<?php }else{ ?>
<div class="box">
<div id="boxcontent">
<?php } ?>